import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;


public class CreadorGrafos {

	
	public void CreaGrafo(String name) throws FileNotFoundException{
		int NNodos = (int) (Math.round(Math.random() * (1000)));
		int Origen = (int)(Math.round(Math.random() * (NNodos-0))) + 0;
		int Destino = (int)(Math.round(Math.random() * (NNodos-0))) + 0;
		
		File fichero = new File(name);
        PrintWriter writer = new PrintWriter(fichero);
        writer.println(NNodos);
        writer.println(Origen);
        writer.println(Destino);

        int indice;
		for (int i =0; i< NNodos;i++){
			indice = i;
			for ( int j =i; j<(NNodos/2) ;j++)
			{
				indice = ((int)(Math.round(Math.random() * (NNodos-(indice+1)))) + indice);
				if (indice !=i)
					writer.println(i+" "+indice+" "+1);
				if (indice == (NNodos-1))
					j=NNodos;
			}
		}
		writer.close();		
	}
}
